package com.bobo.house.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bobo.house.domain.Classify;
import com.bobo.house.domain.Company;
import com.bobo.house.service.CompanyService;
import com.bobo.house.vo.CompanyVO;
import com.github.pagehelper.PageInfo;

@Controller
public class CompanyController {
	@Resource
	CompanyService companyService;

	/**
	 * 列表
	 * @Title: list 
	 * @Description: TODO
	 * @param model
	 * @param companyVO
	 * @param pageNum
	 * @param pageSize
	 * @return
	 * @return: String
	 */
	@RequestMapping("list")
	public String list(Model model, CompanyVO companyVO, @RequestParam(defaultValue = "1") Integer pageNum,
			@RequestParam(defaultValue = "10") Integer pageSize) {
		PageInfo<Company> info = companyService.selects(companyVO, pageNum, pageSize);
		model.addAttribute("info", info);
		model.addAttribute("companyVO", companyVO);

		//查询条件
		
		List<Classify> classifies = companyService.selectsClassify();
		model.addAttribute("classifies", classifies);
		
		//查询概览
		Company company = companyService.selectTotal();
		model.addAttribute("company", company);
		
		return "list";

	}
	/**
	 * 
	 * @Title: deleteCompany 
	 * @Description: 删除公司
	 * @return
	 * @return: boolean
	 */
	@ResponseBody
	@RequestMapping("deleteCompany")
	public boolean deleteCompany(Integer id) {
		
		return companyService.deleteCompany(id);
	}

}
